class Solution {
    func maxArea(_ height: [Int]) -> Int {
        if height.count == 2 {
            return min(height.first!, height.last!) * 1
        }
        var start = 0
        var end = height.count - 1
        var maxArea = 0
        while start < end {
            let minHeight = min(height[start], height[end])
            maxArea = max(minHeight * (end - start),maxArea)
            if minHeight == height[start] {
                start += 1
            }else{
                end -= 1
            }
        }
        return maxArea
    }
}
